// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'

// 全局loadsh
import _ from 'lodash'

// 引入 ele
import ElementUI from 'element-ui'
// 更换主题直接替换 scss 文件
import 'element-ui/lib/theme-chalk/index.css'

// https://vue-particles.netlify.com/
// 粒子特效
// https://www.jianshu.com/p/53199b842d25
import VueParticles from 'vue-particles'

import VueQuillEditor from 'vue-quill-editor'
// require styles 引入样式
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'

// 全局使用 echatrs
import echarts from 'echarts'

// 全局引用 publicJs 的 changeTodata
import publicJs from '@/assets/js/public'

Vue.use(VueParticles)

Vue.prototype.$echarts = echarts

Vue.config.productionTip = false

// 使用loash this._.debounce(this.handleClick,1000,false)
Vue.prototype._ = _

Vue.prototype.$publicJs = publicJs

// 富文本编译器
Vue.use(VueQuillEditor)

// 使用ele 默认大小 和 默认 z-index
Vue.use(ElementUI, { size: 'small', zIndex: 2000 })

// 路由拦截
router.beforeEach((to, from, next) => {
  if (to.meta.requireAuth) { // 判断该路由是否需要登录权限
    if (localStorage.getItem('isLogin') === 'true') {
      next()
    } else {
      next({
        path: '/login'
      })
    }
  } else {
    next()
  }
})

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})
